<?php

/**
 * Feedback filter form base class.
 *
 * @package    Coverd
 * @subpackage filter
 * @author     Cameron Ross
 * @version    SVN: $Id: sfDoctrineFormFilterGeneratedTemplate.php 29570 2010-05-21 14:49:47Z Kris.Wallsmith $
 */
abstract class BaseFeedbackFormFilter extends BaseFormFilterDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'source_id'                   => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Source'), 'add_empty' => true)),
      'title'                       => new sfWidgetFormFilterInput(),
      'content'                     => new sfWidgetFormFilterInput(),
      'name'                        => new sfWidgetFormFilterInput(),
      'rating'                      => new sfWidgetFormFilterInput(),
      'is_read'                     => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'version'                     => new sfWidgetFormFilterInput(),
      'device_type'                 => new sfWidgetFormFilterInput(),
      'submitted_date'              => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate())),
      'retrieved_date'              => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => false)),
      'added_source_refresh_run_id' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('SourceRefreshRun'), 'add_empty' => true)),
    ));

    $this->setValidators(array(
      'source_id'                   => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('Source'), 'column' => 'id')),
      'title'                       => new sfValidatorPass(array('required' => false)),
      'content'                     => new sfValidatorPass(array('required' => false)),
      'name'                        => new sfValidatorPass(array('required' => false)),
      'rating'                      => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'is_read'                     => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'version'                     => new sfValidatorPass(array('required' => false)),
      'device_type'                 => new sfValidatorPass(array('required' => false)),
      'submitted_date'              => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 00:00:00')), 'to_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 23:59:59')))),
      'retrieved_date'              => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 00:00:00')), 'to_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 23:59:59')))),
      'added_source_refresh_run_id' => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('SourceRefreshRun'), 'column' => 'id')),
    ));

    $this->widgetSchema->setNameFormat('feedback_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Feedback';
  }

  public function getFields()
  {
    return array(
      'id'                          => 'Number',
      'source_id'                   => 'ForeignKey',
      'title'                       => 'Text',
      'content'                     => 'Text',
      'name'                        => 'Text',
      'rating'                      => 'Number',
      'is_read'                     => 'Number',
      'version'                     => 'Text',
      'device_type'                 => 'Text',
      'submitted_date'              => 'Date',
      'retrieved_date'              => 'Date',
      'added_source_refresh_run_id' => 'ForeignKey',
    );
  }
}
